
package com.kweative.lingua.server;

import java.util.HashMap;
import java.util.concurrent.ConcurrentMap;

/**
 *
 * @author henrik
 */
public class Config {
    public static final String SESSIONIDNAME = "SIDNAME";
    public static final String SESSIONEXPIRE = "SESEXPIRE";
	private static Config instance = null;
    public static Config instance() {
		if (instance == null)
			instance = new Config();
		return instance;
	}


    private HashMap<String,Application> applications = null;
    private HashMap<String,Object> settings = null;

    private Config() {
        applications = new HashMap<String,Application>();
        settings = new HashMap<String, Object>();
        set(SESSIONIDNAME,"LINGUASID");
        set(SESSIONEXPIRE,1800);
    }

    public Config set(String name,Object value) {
        settings.put(name, value);
        return this;
    }
    public Object get(String name) {
        return settings.get(name);
    }
    public Config addApplication(Application app) {
        if (!applications.containsKey(app.getName()))
            applications.put(app.getName(),app);
        return this;
    }
    public Application getApplication(String name) {
        return applications.get(name);
    }
    public HashMap<String,Application> applications() {
        return applications;
    }
	
}
